using System;
using CommonDomain;

namespace Sponsorship.Domain.PresentTemplates
{
    /// <summary>
    /// Represents a present template in the Sponsorship domain. A present template contains default data for presents.
    /// </summary>
    public class PresentTemplate : RelaxedAggregateBase
    {
        public PresentTemplate(Guid id, PresentData presentData, string comment) : this(id, null)
        {
            if (id == Guid.Empty)
                throw new ArgumentException("Id must not be empty.", "id");

            RaiseEvent(new PresentTemplateEntered(id, presentData, comment));
        }

        // Infrastructure constructor used by AggregateFactory
        private PresentTemplate(Guid id, IMemento snapshot)
        {
            if (snapshot != null)
                throw new NotSupportedException("This class does not support snapshots.");
            Id = id;
        }

        public void Change(PresentData presentData, string comment)
        {
            RaiseEvent(new PresentTemplateChanged(Id, presentData, comment));
        }

        public void Delete()
        {
            RaiseEvent(new PresentTemplateDeleted());
        }

        protected override IMemento GetSnapshot()
        {
            throw new NotSupportedException("This class does not support snapshots.");
        }
    }
}